<?php

declare(strict_types=1);

namespace App\Entity;

use App\Models\OrderReport;

class OrderReportEntity extends ABaseEntity
{
    public function __construct(OrderReport $model)
    {
        $this->model = $model;
    }

    /**
     * 查找末操作的报备记录
     *
     * @return OrderReportEntity|null
     */
    public static function findStateInitByOrderId(int $orderId)
    {
        $model = OrderReport::where('order_id', $orderId)
            ->where('status', OrderReport::STATE_INIT)
            ->orderBy('id', 'desc')
            ->first();

        if ($model === null) {
            return null;
        }

        return new self($model);
    }

    /**
     * @return int
     */
    public function getId()
    {
        return $this->model->id;
    }

    public function setOrderId(int $orderId)
    {
        $this->model->order_id = $orderId;
    }

    /**
     * @return int
     */
    public function getOrderId()
    {
        return $this->model->order_id;
    }

    public function getStatus(): int
    {
        return $this->model->status;
    }

    public function setStatus(int $status): void
    {
        $this->model->status = $status;
    }

    public function getReason(): string
    {
        return (string) $this->model->reason;
    }

    public function setReason(string $reason): void
    {
        $this->model->reason = $reason;
    }

    public function getReasonId(): int
    {
        return $this->model->reason_id;
    }

    public function setReasonId(int $reason_id): void
    {
        $this->model->reason_id = $reason_id;
    }

    /**
     * 用户备注
     *
     * @return string
     */
    public function getRemark()
    {
        return (string) $this->model->remark;
    }

    /**
     * 用户备注
     */
    public function setRemark(string $remark)
    {
        $this->model->remark = $remark;
    }

    public function getCleanerId(): int
    {
        return (int) $this->model->cleaner_id;
    }

    public function setCleanerId(int $cleaner_id): void
    {
        $this->model->cleaner_id = $cleaner_id;
    }

    public function getCleanerName(): string
    {
        return (string) $this->model->cleaner_name;
    }

    public function setCleanerName(string $cleaner_name): void
    {
        $this->model->cleaner_name = $cleaner_name;
    }

    public function getPlanServiceTime(): string
    {
        return $this->model->plan_service_time ?: '';
    }

    public function setPlanServiceTime(string $planServiceTime): void
    {
        !empty($planServiceTime) && $this->model->plan_service_time = $planServiceTime;
    }

    public function getCreatedAt(): string
    {
        return $this->model->created_at ?: '';
    }

    public function setCratedAt(string $createdAt): void
    {
        $this->model->created_at = $createdAt ?: '';
    }

    public function getRejectReason(): string
    {
        return $this->model->reject_reason;
    }

    public function setRejectReason(string $reject_reason): void
    {
        $this->model->reject_reason = $reject_reason;
    }
}
